/*
 * MyProcess.cpp
 *
 *  Created on: 14/07/2009
 *      Author: banouz
 */

#include "MyProcess.h"

MyProcess::MyProcess(UI* u,int id,int pId)
{
    _ui = u;
   _size = 0;
   _workingDirectory = "root/";
   _parent = pId;
   _id = id;

   for (int i = 0; i < 12; i++){
     _pFdTable[i] = -1;
   }

   if (pthread_cond_init(&m_qCond, NULL) != 0)
                  {
                    perror("m_qCond cond var initialization");
                    exit(1);
                  }
   _commands = new vector<string>();
}

MyProcess::~MyProcess()
{
  // TODO Auto-generated destructor stub
}

void MyProcess::start(void* a)
{
}

int MyProcess::setFD(int index,int fdNum){
  if (index >= 12 ){
    perror("Not enough room for setting a new fd for process");
    return -1;
  }
  _pFdTable[index] = fdNum;
}

void MyProcess::wakeup()
   {

        int a = pthread_cond_signal(&m_qCond);
        cout<<"wake " <<a<<endl;
   }
